func monotoneIncreasingDigits(n int) int {
    ans := 0
    intList := []int{}
    
    for n%10 != 0 || n >= 10{
        intList = append(intList, n%10)
        n = (n - n%10) / 10
    }
    index := -1
    for i:=0; i<len(intList)-1 ; i++ {
        if intList[i] < intList[i+1]{
            intList[i] = 9
            index = i
            intList[i+1] -= 1
        }
    }
    for i:=0;i<=index; i++ {
        intList[i] = 9
    }
    for i:=0; i<len(intList); i++ {
        ans += intList[i] * int(exponent(10, uint64(i)))
    }
    return ans
}

func exponent (a,n uint64) uint64  {
	result := uint64(1)
	for i := n ; i > 0; i >>= 1 {
		if i&1 != 0 {
			result *= a
		}
		a *= a
	}
	return result
}